//
//  VKStudyDaCard1Cell.m
//  V-Learn
//
//  Created by liubo on 2019/2/13.
//  Copyright © 2019 yxk. All rights reserved.
//

#import "VKStudyDaCard1Cell.h"

@implementation VKStudyDaCard1Cell{
    UILabel *_titleLabel;
    UIImageView *_arrowImageV;
}

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    VKStudyDaCard1Cell *cell = [tableView dequeueReusableCellWithIdentifier:@"VKStudyDaCard1Cell"];
    if (cell == nil) {
        cell = [[VKStudyDaCard1Cell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"VKStudyDaCard1Cell"];
    }
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    return cell;
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // 点击cell的时候不要变色
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor whiteColor];
        
        // 布局子控件
        [self autoLayout];
    }
    return self;
}

-(void)setModel:(VKStudyDaCardModel *)model{
//    _titleLabel.text = model.leftLabel;
    
    [self downCountAttributedleftString:@"打卡规则: " withRightString:@"规则规则规则规则规则规则规则规则规则规则规则规则规则" withLabel:_titleLabel];
}

- (void)autoLayout{
    
    UILabel *titleLabel = [[UILabel alloc]init];
    _titleLabel = titleLabel;
    titleLabel.numberOfLines = 0;
    [self.contentView addSubview:titleLabel];
//    titleLabel.text = @"打卡规则";
    titleLabel.textColor = [UIColor cz_colorWithRed:62 green:62 blue:62];
    titleLabel.font = [UIFont systemFontOfSize:16];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(self.contentView).offset(18);
        make.right.equalTo(@(-15));
        make.bottom.mas_equalTo(self.contentView).offset(-18);
    }];
    UIView *lineView = [[UIView alloc]init];
    [self.contentView addSubview:lineView];
    lineView.backgroundColor = [UIColor cz_colorWithRed:244 green:244 blue:244];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(@0);
        make.height.equalTo(@1);
        make.bottom.mas_equalTo(self.contentView);
    }];
    
}

- (void)downCountAttributedleftString:(NSString *)leftString withRightString:(NSString *)rightString withLabel:(UILabel *)contentLabel {
    
    // 左边的文字颜色
    NSMutableAttributedString *string = [[NSMutableAttributedString alloc]initWithString:leftString attributes:@{NSForegroundColorAttributeName:[UIColor cz_colorWithRed:238 green:81 blue:39],NSFontAttributeName:[UIFont systemFontOfSize:16.0]}];
    
    // 右边的文字颜色
    NSMutableAttributedString *rightS = [[NSMutableAttributedString alloc]initWithString:rightString attributes:@{NSForegroundColorAttributeName:[UIColor blackColor],NSFontAttributeName:[UIFont systemFontOfSize:16.0]}];
    [string insertAttributedString:rightS atIndex:string.length];
    contentLabel.attributedText = string;
}
@end
